﻿CREATE PROCEDURE [dbo].[proc_Customer_GetExtractList_Service]
	(
		@UserName nvarchar(50)
	)
AS	
--begin tran
Begin
	/*declare @companyid int,@num int
	EXEC @companyid=proc_Company_GetID @UserName,@companyid--单位ID
	Select @num=Count(Id) From Customer Where ProtectName=@UserName and ProtectId=1 and Companyid=@companyid--用户现有的临时客户数
	if(@num=0 and @TCount<=20)
	begin
		EXEC('
		declare @tempTable table(id int identity(1,1),nid int)
		Insert into @tempTable(nid) Select Top '+ @TCount +' Id From Customer  Where Companyid='+ @companyid +' and Audit=1 and ProtectName is null and ProtectId=1 Order by UpTime ASC
		Update Customer Set ProtectName='''+ @UserName +''' Where Id in(Select nid From @tempTable)
		')
	end
	EXEC Customer_GetEmployeeList @UserName*/
	
	select * from customer where ServicePerson = @UserName
	
--commit tran
End
	RETURN
